<?php

/*

example:

new spTimeStamp(array(
	"format"	=> "[date] - [hour]:[minute]:[seconds]"
));

or

new spTimeStamp( "some text to be appended" );

*/

class spTimeStamp
{
	private $param;
	
	public function __construct( $param=null )
	{
		if ( $param==null )
		{
			$this->param = array(
				"format" => "[date] - [hour]:[minute]:[seconds]"
			);
		}
		else if ( is_array($param) )
		{
			$this->param = $param;
		}
		else
		{
			$this->param = array(
				"format" => "[date] - [hour]:[minute]:[seconds] - ".$param
			);
		}
	}

	public function get()
	{
		$date = date("d-m-Y");
		$time = current_time('mysql', 0);
		list( $today_year, $today_month, $today_day, $hour, $minute, $seconds ) = preg_split( '([^0-9])', $time );

		$s = $this->param["format"];
		
		$s = str_replace( "[date]", 	$date, 		$s );
		$s = str_replace( "[hour]", 	$hour, 		$s );
		$s = str_replace( "[minute]", 	$minute, 	$s );
		$s = str_replace( "[seconds]", 	$seconds,	$s );
		
		return $s;
	}
}

?>